package com.aaa.mapper;

import com.aaa.entity.User;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/*@CacheNamespace(implementation = .class)*/

//@CacheNamespace(implementation = MybatisRedisCache.class)
public interface UserMapper {
    /**
     * 查询全部用户信息SQL
     *
     * @return 返回数据
     */

    @Select("<script>" +
            "select * from hotels.user where 1=1" +
            "<if test='uname!=null and uname!=\"\" '>" +
            "   and uname like '%' #{uname}  '%'" +
            "</if>" +
            "<if test='phone!=null and phone!=\"\"'>" +
            "   or phone like '%' #{phone} '%'" +
            "</if>" +
            "</script>"
    )
    List<User> query(String uname, String phone);

    /**
     * 修改用户状态
     *
     * @param id    根据主键
     * @param state 修改对象
     * @return 返回数据
     */
    @Update("update hotels.user set user.state  = if(#{state}='禁用','正常','禁用') where id=#{id} and state=#{state}")
    Integer updState(Integer id, String state);
}
